global gSimObject, gTruckObject, gLevelObject, gGasGaugeObject, gCDpath, gRollAnimButton, gCulvertObject, gDebug, gFileSep
on checkBlockage adjCell, adjObj, adjVector
set blockedFlag to 0
set riverTileName to char 1 of the name of cast the tileNum of adjObj
set bridgeList to getProp(the bridgeList of gSimObject, riverTileName)
set bridgeData to getProp(bridgeList, adjVector)
set exitDir to getAt(bridgeData, 2)
set otherSideCell to adjCell + getProp(the moveList of gSimObject, exitDir)
set otherSideObj to getAt(the cellList of gSimObject, otherSideCell)
if getPos(the adjacentList of adjObj, exitDir) = 0 then
set blockedFlag to 1
end if
if (the tileType of otherSideObj = #Road) or (the tileType of otherSideObj = #Bridge) or (the tileType of otherSideObj = #Building) or (the tileType of otherSideObj = #immovable) or (the tileType of otherSideObj = #River) then
set blockedFlag to 1
end if
return blockedFlag
end
on placeObstacle obstacleDataList
set options to (count(obstacleDataList) - 1) / 3
set probability to getLast(obstacleDataList)
repeat with cell = 1 to count(the cellList of gSimObject)
if getOne(the pathList of gSimObject, cell) = 0 then
set cellObj to getAt(the cellList of gSimObject, cell)
if the tileType of cellObj = #BG then
if random(100) <= probability then
set choice to (random(options) - 1) * 3
set the tileType of cellObj to getAt(obstacleDataList, choice + 1)
set firstTileNum to getAt(obstacleDataList, choice + 2)
set variations to getAt(obstacleDataList, choice + 3)
set the tileNum of cellObj to firstTileNum + random(variations) - 1
set the startTileType of cellObj to the tileType of cellObj
set the startTileNum of cellObj to the tileNum of cellObj
end if
end if
end if
end repeat
end
on navButtonHandler
set simButList to the simButtonList of gSimObject
if the status of gTruckObject <> #animating then
if not objectp(gRollAnimButton) and (the available of getProp(simButList, #alert) <> 1) then
if buttonHandler() = 1 then
startBuffering()
puppetSound("arrowClick")
updateStage()
if the startSimFlag of gSimObject = 1 then
set the startSimFlag of gSimObject to 0
end if
set whichbutton to the clickOn - the channel of getProp(simButList, #n) + 1
set move to getPropAt(simButList, whichbutton)
repeat while soundBusy(1)
end repeat
puppetSound(0)
moveTruck(gTruckObject, move)
flushBuffer()
end if
end if
end if
end
on refreshControls availableMoveList
repeat with x = 1 to 8
set position to getPos(availableMoveList, getAt(the arrowList of gSimObject, x))
set buttonObject to getAt(the simButtonList of gSimObject, x)
if position = 0 then
set the available of buttonObject to 0
set the locH of sprite the channel of buttonObject to 1000
next repeat
end if
set the available of buttonObject to 1
set the locH of sprite the channel of buttonObject to the locH of getAt(the simButtonList of gSimObject, x)
end repeat
end
on resetGame
puppetSound("RESETSIM")
removeMessage()
showDemoButton()
set the startSimFlag of gSimObject to 1
set the finishedFlag of gSimObject to 0
set the demoFlag of gSimObject to 0
set the buildingsConnected of gSimObject to 0
hideInvisibleButtons(gSimObject)
set the invisibleButtonList of gSimObject to [0, 0, 0, 0, 0, 0, 0, 0]
erasePlayfield(gSimObject)
repeat with x = 1 to count(the cellList of gSimObject)
set cellObj to getAt(the cellList of gSimObject, x)
if the tileType of cellObj = #Road then
set the connector of cellObj to 0
else
if the tileType of cellObj = #Building then
set the connector of cellObj to 0
end if
end if
set the tileNum of cellObj to the startTileNum of cellObj
set the tileType of cellObj to the startTileType of cellObj
initAdjacentList(cellObj)
end repeat
initTruckProps(gTruckObject, the firstCell of gTruckObject, the startDirection of gTruckObject)
set availableMoveList to createAvailableList(gTruckObject, the cell of gTruckObject)